<template>
	<div class="header_common">
		<div class="header_main">
			<div class="header_left">“到此一玩”运营管理后台</div>
			<div class="header_right">
				<div class="header_name">{{userName}}</div>
				<div class="header_login" v-on:click="logout()">退出</div>
			</div>
		</div>
	</div>
</template>

<script>
	import store from '../vuex/store'
	export default {
		name: 'header',
		data() {
			return {
				title: '',
				userName:cookie().get("user").userName
			}
		},
		computed: {
			
		},
		components: {
			
		}, //这里注册
		methods: {},
		mounted() {
			var that = this;
			this.get_navigation();
		},
		methods: {
			logout: function() {
				var that=this
				cookie().del('user')
				that.$router.push({
					path: '/'
				})
			},
			get_navigation() {
				var path = this.$route.path.split('/')[1]
				switch(path) {
					case 'reg':
						this.navigation_title = '用户注册'
						this.navigation = false
						break;
					case 'setpassword':
						this.navigation_title = '用户注册'
						this.navigation = false
						break;
					case 'findpassword':
						this.navigation_title = '找回密码'
						this.navigation = false
						break;
					case 'login':
						this.navigation_title = '用户登录'
						this.navigation = false
						break;
					default:
						this.navigation = true
						break;
				}
			}
		},
		watch: {
			'$route' (to, from) {
				console.log(2222)
					// 对路由变化作出响应...
				this.get_navigation();
			}
		},
		beforeCreate:function(){
			var that = this;
			var user=cookie().get("user")
			that.userName=user.userName
		}
	}
</script>

<style lang="scss">
	.header_common{
		width:100%;
		height:70px;
		background:rgba(0,0,0,0.2);
		.header_main{
			width:1300px;
			height:70px;
			margin:0 auto;
			.header_left{
				float:left;
				width:400px;
				height:70px;
				text-align: left;
				line-height:70px;
				font-size:24px;
			}
			.header_right{
				width:200px;
				height:70px;
				line-height: 70px;
				float:right;
				font-size:18px;
				.header_name{
					width:140px;
					height:25px;
					text-align: right;
					margin-top:25px;
					line-height: 25px;
					border-right:#999 solid 1px;
					float: left;
					padding-right:10px;
				}
				.header_login{
					width:50px;
					height:25px;
					margin-top:25px;
					line-height: 25px;
					text-align: left;
					float: right;
					cursor: pointer;
				}
			}
		}
	}
</style>